package com.xinfu.newproject.adapter.certification;


import android.view.View;

import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xinfu.newproject.R;
import com.xinfu.newproject.bean.certifition.ResidentBean;
import com.xinfu.newproject.bean.certifition.ResidentCertificationBean;

import java.util.List;

/**
 * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
 */
public class ResidentCertificationAdapter extends BaseSectionQuickAdapter<ResidentBean, BaseViewHolder> {
    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param sectionHeadResId The section head layout id for each item
     * @param layoutResId      The layout resource id of each item.
     * @param data             A new list is created out of this one to avoid mutable list
     */
    public ResidentCertificationAdapter(int layoutResId, int sectionHeadResId, List data) {
        super(layoutResId, sectionHeadResId, data);
    }


    @Override
    protected void convertHead(BaseViewHolder helper, ResidentBean item) {
        View v = helper.getView(R.id.item_resident_certification_head_v);
        if (item.header.equals(mData.get(0).header)) {
            v.setVisibility(View.GONE);
        } else {
            v.setVisibility(View.VISIBLE);
        }
        helper.setText(R.id.item_resident_certification_head_tv, item.header);
    }

    @Override
    protected void convert(BaseViewHolder helper, ResidentBean item) {
        ResidentCertificationBean.ResultBean.RoomCheckUserListBean video = (ResidentCertificationBean.ResultBean.RoomCheckUserListBean) item.t;

        helper.setText(R.id.item_resident_certification_address, video.getAddress());
        if (video.getAuditRes() == 0) {
            helper.setText(R.id.item_resident_certification_status, "审核中");
            helper.setTextColor(R.id.item_resident_certification_status, mContext.getResources().getColor(R.color.blue_4a));
        } else if (video.getAuditRes() == 1) {
            helper.setText(R.id.item_resident_certification_status, "认证成功");
            helper.setTextColor(R.id.item_resident_certification_status, mContext.getResources().getColor(R.color.green_37));
        } else if (video.getAuditRes() == -1) {
            helper.setText(R.id.item_resident_certification_status, "已驳回");
            helper.setTextColor(R.id.item_resident_certification_status, mContext.getResources().getColor(R.color.yellow_ff));
        }
    }
}
